#include <ros/ros.h>
#include  <std_msgs/String.h>
#include <sensor_msgs/BatteryState.h>
#include "serial/serial.h"

using namespace std;

class Battery {
public:
    Battery(ros::NodeHandle nh, ros::NodeHandle n);
    ~Battery();
    bool spin();

public:
    ros::NodeHandle node_handle_;
	ros::NodeHandle node_h_;

private:
   serial:: Serial *batSerial;
   //通信命令
   string analog_quantity;      //获取Pack模拟量
   string warning_lamp;         //获取告警量
   string pack_quantity;        //获取Pack数量
   string control_command;  //控制命令
   string charge_control_mos;   //充电MOS控制
   string discharge_control_mos;    //放电MOS控制
   string forced_shutdwn;           //软件强制休眠/关机
   string get_version;          //获取软件版本信息
   string r_BMS_code;       //获取BMS条形码信息
   string w_BMS_code;       //写入BMS条形码信息
   //ROS
   ros::Publisher battery_pub;
   sensor_msgs::BatteryState _battery;

   string _port;
   int _frequency;
   int _version;
   
   //64v
   //sensor_msgs::BatteryState battery_analog_64v;

private:
   void analogParse(string _data);
   void analogParse_64V(string _data);
   void analogParse_64V_warning(string _data);
   void analogParseJG(uint8_t *data_);
};


